<template>
    <transition :name="animateName" appear>
        <div class="alerts" :class="alertsCls" v-if="show.value">
            <div class="alerts__img">
                <div class="alerts__img__txt">{{ text.value }}</div>
            </div>
        </div>
    </transition>
</template>
<script setup>
    import {
        ref,
        computed
    } from 'vue'
    const animateName = ref('opacity')
    const props = defineProps({
        type: Object,
        show: Object,
        wordWrap: Object,
        width: Object,
        text: Object,
    })
    const alertsCls = computed(() => {
        if (props.type.value) {
            return `alert_${props.type.value}`
        }
        return ''

    })
</script>
<style scoped>
    .alerts {
        position: fixed;
        z-index: 9999999;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        background: transparent;
    }

    .alerts__img {
        position: absolute;
        top: 50%;
        left: 50%;
        -webkit-transform: translate3d(-50%, -50%, 0);
        transform: translate3d(-50%, -50%, 0);
        color: #fff;
        padding: .2rem .4rem;
        border-radius: .1rem;
        text-align: center;
        background-color: rgba(49, 52, 68, .9);
        box-shadow: 0 8px 20px 0 rgba(0, 0, 0, .2);
        background-repeat: no-repeat;
        background-position: .14rem 50%;
    }

    .alert_success .alerts__img {
        background-image: url();
        background-size: .5rem auto;
        padding-left: .8rem;
        text-align: left;
    }

    .alert_error .alerts__img {
        background-image: url();
        background-size: .5rem auto;
        padding-left: .8rem;
        text-align: left;
    }

    .alerts__img__txt {
        font-size: .28rem;
    }

    .alerts__img img {
        width: .7rem;
        margin-bottom: .1rem;
    }

    .alerts__loader {
        position: absolute;
        top: 50%;
        left: 50%;
        -webkit-transform: translate3d(-50%, -50%, 0);
        transform: translate3d(-50%, -50%, 0);
        display: none;
    }

    .alerts__loader__dot {
        width: .23rem;
        height: .23rem;
        background: #3ac;
        border-radius: 100%;
        display: inline-block;
        -webkit-animation: slide 1s infinite;
        animation: slide 1s infinite;
        margin-right: .2rem;
    }

    .alerts__loader__dot:first-child {
        -webkit-animation-delay: .3s;
        animation-delay: .3s;
        background: #dc3535;
    }

    .alerts__loader__dot:nth-child(2) {
        -webkit-animation-delay: .4s;
        animation-delay: .4s;
        background: #e04f4f;
    }

    .alerts__loader__dot:nth-child(3) {
        -webkit-animation-delay: .5s;
        animation-delay: .5s;
        background: #e56969;
    }

    .alerts__loader__dot:nth-child(4) {
        -webkit-animation-delay: .6s;
        animation-delay: .6s;
        background: #e98383;
    }

    .alerts__loader__dot:nth-child(5) {
        -webkit-animation-delay: .7s;
        animation-delay: .7s;
        background: #ee9d9d;
    }

    .opacity-enter-active {
        animation: sf-fade-in .4s
    }

    .opacity-leave-active {
        animation: sf-fade-out .4s
    }


    @keyframes sf-fade-in {
        0% {
            opacity: 0;
            transform: translate3d(0, -10px, 0);
        }
    }

    @keyframes sf-fade-out {
        100% {
            opacity: 0;
            transform: translate3d(0, 10px, 0);
        }
    }
</style>